package top.toptimus.dto.dbSync.syncDatas;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@NoArgsConstructor
@AllArgsConstructor
@Data

/**
 * 库存材料DTO
 */

public class InventoryMaterIalDTO {

    private String inventory_material_id;//库存材料ID
    private String material_quantity;    //库存数量
    private String material_id;        //原辅料ID

    /**
     * 数据放在map集合中
     *
     * @param map
     */
    public InventoryMaterIalDTO(Map<String, Object> map) {
        this.inventory_material_id = map.containsKey("inventory_material_id")?map.get("inventory_material_id").toString():"";
        this.material_quantity =map.containsKey("material_quantity")? map.get("material_quantity").toString():"";
        this.material_id = map.containsKey("material_id")?map.get("material_id").toString():"";


    }

    /**
     * 插入i_inventory_material_p表数据
     *
     * @return
     */
    public String InventoryMaterIalSql() {
        String sql = "INSERT INTO `fragsmart-erp`.`i_inventory_material_p` ( `inventory_material_id`, `material_quantity`, `material_id` )\n" +
                "VALUES\n" +
                "	( " + this.inventory_material_id + ", " + this.material_quantity + ", " + this.material_id + " );";

        return sql;
    }
}
